package org.demo.five;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

/**
 * 
 * @author  
 * @date    2010-10-26
 * @file    org.demo.five.Ping.java
 */
public class Ping {

	/**
	 * @param args
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws InterruptedException {
		Runnable pingers = new Runnable(){
			@Override
			public void run() {
				System.out.println("ping.");
			}
		};
		ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
		ScheduledFuture<?> sf = ses.scheduleAtFixedRate(pingers, 1, 5, TimeUnit.SECONDS);
		Thread.sleep(TimeUnit.SECONDS.toMillis(10));
		//sf.cancel(true);
	}

}
